<?php
/*
* Class teia\webdev\php\core\Catalog
* Core catalog
*
* @author Bernardo Quibiana
* @date created: 20111122
*
* @date modified: 20111122
* @modified: Bernardo Quibiana
*/

// namespace declaration: Abstract Data Types
namespace teia\webdev\php\core;

class LinkUtil {
	
	static function generate_prod_item_link($prod_obj, $item_obj) {
		$prod_id = $prod_obj->get_prod_id();
		$prod_gender = $prod_obj->get('prod_gender');
		//$prod_type = $prod_obj->get('prod_type');
		$item_id = $item_obj->get_item_id();
		
		$dir = '';
		switch ($prod_gender) {
			case 'F': $dir = '/mulher/'; break;
			case 'M': $dir = '/homem/'; break;
			default: $dir = '/'; break;
		}
		
		return $dir . "product.php?prod_id=$prod_id&item_id=$item_id";
	}
	
	static function generate_prod_item_onchange($field) {
		$query = array('field' => $field, 'value' => '');
		$link = FunctionPool::get_request_url(null, $query);
		$onchange = "window.location='$link' + this.options[this.selectedIndex].value;";
		
		return $onchange;
	}
	
	static function generate_javascript_link($queries, $ignore_old=FALSE) {
		$link = FunctionPool::get_request_url(null, $queries, $ignore_old);
		return "window.location='$link';";
	}
}
?>